<template>
  <basic-container :btnFlag="true">
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <!-- 搜索栏 -->
      <form class="el-form el-form--inline avue-crud__search"
            style="margin: 14px 0px -7px 15px">
        <div class="el-form-item">
          <label class="el-form-item__label">规划名称:</label>
          <div class="el-form-item__content">
            <el-input v-model="plantitle"
                      size="small"
                      placeholder="请输入内容"
                      clearable></el-input>
          </div>
        </div>
        <div class="el-form-item avue-crud__searchMenu">
          <div class="el-form-item__content">
            <el-button class="myBtn" type="primary" icon="el-icon-search" @click.stop="searchSubmit()">搜索</el-button>
            <el-button class="myBtn" type="reset" icon="el-icon-delete" @click.stop="resetSubmit()">重置</el-button>
            <!--<el-button type="warning"-->
                       <!--size="small"-->
                       <!--@click.stop="searchSubmit()">查询-->
            <!--</el-button>-->
          </div>
        </div>
      </form>
      <div class="card-body">
        <el-table :data="tableData"
                  style="width: 100%"
                  row-key="id"
                  :row-class-name="tableRowClassName"
                  border
                  default-expand-all
                  :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                  ref="pimTreeTable">
          <el-table-column align="left"
                           label="名称"
                           width="320">
            <template slot-scope="scope">
              <a style="cursor:pointer;"
                 @click="detailDialog(scope.row.achievementId,scope.row.pmuc)"
                 v-if="scope.row.children||scope.row.children===null">{{scope.row.mainTitle}}</a>
              <a style="cursor:pointer;"
                 @click="watchDetail(scope.row)"
                 v-else-if="scope.row.reportType==1">{{scope.row.year+scope.row.mainTitle}}</a>
              <a style="cursor:pointer;"
                 @click="watchDetail(scope.row)"
                 v-else>{{scope.row.mainTitle}}</a>
            </template>
          </el-table-column>
          <el-table-column align="center"
                           prop="createUnit"
                           label="起草单位"
                           width="120"></el-table-column>
          <el-table-column align="center"
                           prop="createTime"
                           label="起草时间"
                           :formatter="formatterTime"></el-table-column>
          <el-table-column align="center"
                           prop="reportState"
                           label="状态"
                           :formatter="formatterState"></el-table-column>
          <el-table-column align="center"
                           width="310">
            <template slot="header"
                      slot-scope="scope">
              <span>操作</span>
            </template>
            <template slot-scope="scope">
              <div class="menu-title"
                   @click.stop="draftPlan(scope.row,scope.index)"
                   v-if="!scope.row.isReport&&scope.row.deptOperable!='0'">
                <i class="iconfont iconalter icon-warning"></i>
                <p class="menu-title-text">起草报告</p>
              </div>
              <!-- cbx---暂时隐藏掉 找不到文件 -->
              <!-- <div class="menu-title"
                   @click.stop="templateConsult(scope.row,scope.index)"
                   v-if="!scope.row.isReport&&scope.row.deptOperable!='0'">
                <i class="iconfont iconflow_chart icon-warning"></i>
                <p class="menu-title-text">模板参考</p>
              </div> -->
              <div class="menu-title"
                   @click.stop="checkProgress(scope.row,scope.index)"
                   v-if="!scope.row.isReport">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">实施进度</p>
              </div>

              <div class="menu-title"
                   @click.stop="solicitOpinions(scope.row)"
                   v-if="scope.row.isReport&&scope.row.reportState=='1'&&scope.row.deptOperable!='0'">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">征求意见</p>
              </div>
              <div class="menu-title"
                   @click.stop="reportOpinionHistory(scope.row,scope.index)"
                   v-if="scope.row.isReport&&scope.row.reportState!='1'">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">查看反馈</p>
              </div>
              <div class="menu-title"
                   @click.stop="viewReportRrogress(scope.row,scope.index)"
                   v-if="scope.row.isReport&&scope.row.reportState!='1'&&scope.row.reportState!='2'&&scope.row.reportType=='2'&&scope.row.category=='A'">
                <i class="iconfont iconalter icon-warning"></i>
                <p class="menu-title-text">流程进度</p>
              </div>
              <div class="menu-title"
                   @click.stop="modifyPlan(scope.row,'1')"
                   v-if="scope.row.isReport&&(scope.row.reportState=='1'||scope.row.reportState=='2')&&scope.row.deptOperable!='0'">
                <i class="iconfont iconalter icon-warning"></i>
                <p class="menu-title-text">修改报告</p>
              </div>
              <div class="menu-title"
                   @click.stop="releaseReport(scope.row)"
                   v-if="scope.row.isReport&&(scope.row.reportState=='1'||scope.row.reportState=='2')&&scope.row.deptOperable!='0'">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">上报报告</p>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div>
          <el-pagination @size-change="handleSizeChange"
                         @current-change="handleCurrentChange"
                         :page-sizes="[1, 2, 5, 10, 20, 30, 40 ,50]"
                         :current-page="page.currentPage"
                         :page-size="page.pageSize"
                         :total="page.total"
                         layout="total, sizes, prev, pager, next, jumper"
                         class="paginationcss"></el-pagination>
        </div>
      </div>
    </div>
    <el-dialog :title="look?'查看报告':modifyReportId?'修改报告':'起草报告'"
               :visible.sync="reportVisible"
               @closed="close"
               width="70%">
      <el-form ref="projectForm"
               :model="projectForm"
               label-width="180px">
        <el-row>
          <el-col :span="10">
            <el-form-item label="报告名称 :"
                          :required="true">
              <el-select v-model="projectForm.type"
                         placeholder="请选择报告类型"
                         :key="2"
                         :disabled="modifyReportId?true:false">
                <el-option v-for="li in reportNameList"
                           :key="li.type"
                           :value="li.type"
                           :label="li.name"
                           :disabled="li.disable"></el-option>
              </el-select>

            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item v-if="projectForm.type==1"
                          label="年份:"
                          :required="true">
              <el-date-picker v-model="projectForm.year"
                              :disabled='look'
                              value-format='yyyy'
                              type="year"
                              placeholder="选择年">
              </el-date-picker>

            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="相关报告 :"
                      v-if="!look"
                      :required="true">
          <el-upload class="uploadFile"
                     action="string"
                     :limit="1"
                     :on-exceed="tipFileOne"
                     :http-request="basisSubmitUploadMixin"
                     :on-change="basisFileChangeMixin"
                     :on-preview="basishandlePreviewMixin"
                     :on-remove="basishandleRemoveMixin"
                     :auto-upload="true"
                     :file-list="basisFileListMixin">
            <el-button size="small"
                       type="primary">报告上传
            </el-button>
            <div slot="tip"
                 class="el-upload__tip"
                 style="margin-top: -8px;">请上传报告材料
            </div>
          </el-upload>
        </el-form-item>
        <el-row>
          <el-col :span="12"
                  class="report">
            <el-form-item label="报告 ："
                          v-if="files.length">
              <div style="font-size:14px;color:#606266">
                <div v-for="(file,index) in files"
                     :key="index"
                     class="relateddiv">
                  <el-tooltip class="item"
                              effect="dark"
                              content="下载资料"
                              placement="top-start">
                    <el-button class="downbtn"
                                @click="downloadFile(file.fileId,file.fileName)">
                      <img src="img/download-blue.png"
                           class="detail-data-img" />
                      <span>下载</span>
                    </el-button>
                  </el-tooltip>
                  <p class="detail-data-file"
                     v-if="file.fileName">{{file.fileName}}</p>
                </div>
                <p class="detail-data-file"
                   v-if="files.length==0">无</p>
              </div>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="相关附件 :"
                      v-if="!look">
          <el-upload class="upload-demo"
                     ref="uploadrelated"
                     action="string"
                     :http-request="submitUploadMixin"
                     :on-preview="handlePreviewMixin"
                     :on-remove="handleRemoveMixin"
                     :file-list="fileListMixin"
                     :auto-upload="true"
                     :on-change="fileChangeMixin">
            <el-button slot="trigger"
                       size="small"
                       type="primary">附件上传
            </el-button>
            <div slot="tip"
                 class="el-upload__tip"
                 style="margin-top: -8px;">请上传附件材料（支持上传多个文件）
            </div>
          </el-upload>
        </el-form-item>

        <el-row>
          <el-col :span="12"
                  class="report">
            <el-form-item label="附件 ："
                          v-if="material_fileIds.length">
              <div style="font-size:14px;color:#606266">
                <div v-for="(file,index) in material_fileIds"
                     :key="index"
                     class="relateddiv">
                  <el-tooltip class="item"
                              effect="dark"
                              content="下载资料"
                              placement="top-start">
                    <el-button class="downbtn"
                               @click="downloadFile(file.fileId,file.fileName)">
                      <img src="img/download-blue.png"
                           class="detail-data-img" />
                      <span>下载</span>
                    </el-button>
                  </el-tooltip>
                  <p class="detail-data-file"
                     v-if="file.fileName">{{file.fileName}}</p>
                </div>
                <p class="detail-data-file"
                   v-if="material_fileIds.length==0">无</p>
              </div>

            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="proposal&&projectForm.type=='2'"
                v-show="modifyReportId?false:true">
          <el-col :span="12">
            <el-form-item label="有无修订调整建议 ：">
              <el-radio v-model="havModifyOpinion"
                        :label="true">有
              </el-radio>
              <el-radio v-model="havModifyOpinion"
                        :label="false">无
              </el-radio>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="proposal&&projectForm.type=='2'&&havModifyOpinion||(projectForm.modifyOpinion||modifyOpinion_fileIds.length&&modifyReportId)">
          <el-col :span="12">
            <el-form-item label="修订调整建议 ：">
              <el-input type="textarea"
                        :rows="2"
                        :disabled="look"
                        placeholder="请输入修订调整建议"
                        v-model="projectForm.modifyOpinion">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-show="!look"
                v-if="proposal&&projectForm.type=='2'&&havModifyOpinion||(projectForm.modifyOpinion||modifyOpinion_fileIds.length&&modifyReportId)">
          <el-col :span="12">
            <el-form-item label="相关修订调整建议附件 ："
                          required="true">
              <el-upload class="upload-demo"
                         ref="upload"
                         :limit="1"
                         :on-exceed="tipFileOne"
                         action="string"
                         :http-request="submitUploadtextMixin"
                         :on-preview="handlePreviewtextMixin"
                         :on-remove="handleRemovetextMixin"
                         :file-list="fileListtextMixin"
                         :auto-upload="true"
                         :on-change="fileChangetextMixin">
                <el-button slot="trigger"
                           size="small"
                           type="primary">点击上传
                </el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
                  class="report">
            <el-form-item label="修订调整建议附件 ："
                          v-if="modifyOpinion_fileIds.length">
              <div style="font-size:14px;color:#606266">
                <div v-for="(file,index) in modifyOpinion_fileIds"
                     :key="index"
                     class="relateddiv">
                  <el-tooltip class="item"
                              effect="dark"
                              content="下载资料"
                              placement="top-start">
                    <el-button class="downbtn"
                               @click="downloadFile(file.fileId,file.fileName)">
                      <img src="img/download-blue.png"
                           class="detail-data-img" />
                      <span>下载</span>
                    </el-button>
                  </el-tooltip>
                  <p class="detail-data-file"
                     v-if="file.fileName">{{file.fileName}}</p>
                </div>
                <p class="detail-data-file"
                   v-if="modifyOpinion_fileIds.length==0">无</p>
              </div>

            </el-form-item>
          </el-col>
        </el-row>

      </el-form>

      <div style="text-align:center">
        <el-button type="primary"
                   v-if="!modifyReportId"
                   @click="add()">新增
        </el-button>
        <el-button type="primary"
                   v-else-if="!look"
                   @click="modify()">修改
        </el-button>
        <el-button @click="reportVisible=false">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog title="报告进度"
               :visible.sync="reportRrogressVisible"
               @close="reportClose"
               width="1150px">
      <div class="step-group"
           style="margin: 20px;margin-bottom: 1px;"
           v-if="reportRrogressMedium">
        <el-steps v-if="!havModifyIf"
                  :active="reportRrogressStep">
          <el-step :title="reportStepOne"
                   icon="el-icon-edit"></el-step>
          <el-step title="政府"
                   icon="el-icon-upload"></el-step>
          <el-step title="人大"
                   icon="el-icon-picture"></el-step>
          <el-step title="抄送"
                   icon="el-icon-upload"></el-step>
        </el-steps>
        <el-steps v-else
                  :active="reportRrogressStep">
          <el-step title="上报报告"
                   icon="el-icon-edit"></el-step>
          <el-step title="政府"
                   icon="el-icon-edit"
                   class="transform-deg_two"></el-step>
          <el-step title=""
                   icon="el-icon-edit"
                   class="transform-deg_line_two"></el-step>
          <el-step title="党委"
                   icon="el-icon-upload"
                   :class="{'reportTwoValidate':reportTwoValidate}"
                   class="beian_two"></el-step>
          <el-step title="人大"
                   icon="el-icon-upload"
                   style="margin-top:-8px;margin-left: -266px;"></el-step>

        </el-steps>
      </div>
      <div class="step-group"
           style="margin: 20px;margin-bottom: 1px;"
           v-if="reportRrogressOthers">
        <el-steps :active="reportRrogressStepOthers">
          <el-step title="上报报告"
                   icon="el-icon-edit"></el-step>
          <el-step :title="reportRrogressOthersStep"
                   icon="el-icon-upload"></el-step>
        </el-steps>
      </div>
      <div style="text-align:right;margin: 40px 8px 0 0;">
        <el-button @click="reportRrogressVisible=false">关 闭</el-button>
      </div>
    </el-dialog>
    <el-dialog title="模板参考"
               :visible.sync="templateVisible"
               width="60%">
      <el-form>
        <el-row>
          <el-col :span="10">
            <el-form-item label="发展规划模板参考 :">
              <el-link type="danger"
                       href="./发展规划模板.doc">发展规划模板.doc
              </el-link>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
    <detail-dialog :achievementId="achievementIdDD"
                   :pmuc="pmucDD"
                   :showDetailDialog.sync="showDetailDialog"
                   :key="achievementIdDD"></detail-dialog>
  </basic-container>
</template>

<script>
import basisfile from "@/mixins/basisfile";
import relatedfile from "@/mixins/relatedfile";
import textfile from "@/mixins/textfile";
import { filedownload } from "@/api/system";
import todoWorkitem from "@/views/pim/todoWorkItem";
import { decomposeDraftDetailList, releaseReport, judgeExist } from "@/api/pim/pim";

import {
  getPlanReportPageTree,
  addReport,
  getReportDetail,
  modifyReport
} from "@/api/pim/pim";
import { getFileTypeFiles } from "@/views/util";

export default {
  name: "monitorList",
  created () {
    window.detailDialog = this.detailDialog;
    this.putTableData();
  },
  mixins: [basisfile, relatedfile, textfile],
  components: {
    todoWorkitem
  },
  data () {
    return {
      reportTwoValidate: false,
      havModifyIf: false,
      templateVisible: false,
      havModifyOpinion: false,
      modifyOpinion_fileIds: [],
      proposal: false,
      reportList: "",
      files: [],
      projectForm: {
        basisFileId: null,
        type: "",
        year: '',
        modifyOpinion: ''
      },
      childrenLength: 0,
      reportNameList: [
        { name: "年度监测分析报告", type: "1", disable: false },
        { name: "中期评估报告", type: "2", disable: false },
        { name: "期末总结报告", type: "3", disable: false }
      ],
      reportVisible: false,
      headerData: {
        title: "监测评估"
      },
      tableData: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 5 // 每页显示多少条
      },
      formatterTime: function (row, value, label, column) {
        if (row.createTime != null) {
          var data = row.createTime.split(" ");
          return data[0];
        }
      },
      formatterState: function (row, value, label, column) {
        switch (row.reportState) {
          case '1':
            return "已起草";
            break;
          case '2':
            return "征求意见";
            break;
          case '3':
            return "已上报";
            break;
          case '4':
            return "待修改";
            break;
          case '5':
            return "已审定";
            break;
          case '6':
            return "已审议";
            break;
          case '7':
            return "退回中";
            break;
          case '8':
            return "待修改";
            break;
        }
      },
      achievementIdForcheck: 0,
      selectedSubjectIds: [],
      typetemp: "",
      plantitle: "",
      modifyReportId: "", //被修改报告id
      look: false, //是否查看,
      material_fileIds: [],//相关附件材料
      reportRrogressVisible: false,
      reportRrogressStep: 1,
      reportRrogressStepOthers: 0,
      reportRrogressMedium: false,
      reportRrogressOthers: false,
      reportStepOne: '上报报告',
      reportRrogressOthersStep: '报送',
      achievementIdDD: null,
      pmucDD: null,
      showDetailDialog: null,

    };
  },
  methods: {
    reportClose () {
      this.reportTwoValidate = false
    },
    templateConsult (row, index) {
      this.templateVisible = true
    },
    //查看进度
    checkProgress (row) {
      let src = `/pim/progressDetail`;
      this.$router.push({
        path: src,
        query: {
          pmuc: row.pmuc
        }
      })
    },
    //修改报告
    modify () {
      if (!this.basisFileListMixin.length) {
        this.$notify({
          title: "警告",
          message: "请上传报告",
          type: "warning",
          duration: 2000
        });
        return;
      }
      if (!this.projectForm.year && this.projectForm.type == 1) {
        this.$notify({
          title: "警告",
          message: "请选择年份",
          type: "warning",
          duration: 2000
        });
        return;
      }
      let fileIds = [];
      for (let item in this.basisFileListMixin) {
        fileIds.push(this.basisFileListMixin[item].url);
      }
      let material_fileIds = [];
      for (let item in this.fileListMixin) {
        material_fileIds.push(this.fileListMixin[item].url);
      }
      let modifyOpinion_fileIds = [];
      for (let item in this.fileListtextMixin) {
        modifyOpinion_fileIds.push(this.fileListtextMixin[item].url);
      }
      this.$confirm("确认修改?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        modifyReport(this.modifyReportId, {
          fileIds: fileIds,
          material_fileIds: material_fileIds,
          year: this.projectForm.year,
          modifyOpinion_fileIds: modifyOpinion_fileIds,
          modifyOpinion: this.projectForm.modifyOpinion,
        }).then(response => {
          if (response.data.code == 0) {
            this.$notify({
              title: "成功",
              message: "修改成功",
              type: "success",
              duration: 2000
            });
            this.reportVisible = false;
            this.putTableData();
          }
        });
      });
    },
    //查看详情
    watchDetail (row) {
      this.reportVisible = true;
      this.look = true;
      this.modifyReportId = row.reportId;
      getReportDetail(row.reportId).then(async response => {
        if (response.data.code == 0) {
          let fileIds = response.data.data.fileIds;
          let material_fileIds = response.data.data.material_fileIds;
          let modifyOpinion_fileIds = response.data.data.modifyOpinion_fileIds;
          this.projectForm.type = response.data.data.reportType;
          this.projectForm.year = response.data.data.year;
          this.projectForm.modifyOpinion = response.data.data.modifyOpinion;
          if (fileIds != null) {
            this.files = await getFileTypeFiles(fileIds);
          }
          if (material_fileIds != null) {
            this.material_fileIds = await getFileTypeFiles(material_fileIds);
          }
          if (modifyOpinion_fileIds != null) {
            this.modifyOpinion_fileIds = await getFileTypeFiles(modifyOpinion_fileIds);
          }
        }
      });
    },
    //获取被修改报告信息
    modifyPlan (row) {
      this.proposal = true;
      this.reportVisible = true;
      this.modifyReportId = row.reportId;
      getReportDetail(row.reportId).then(async response => {
        if (response.data.code == 0) {
          let fileIds = response.data.data.fileIds;
          let material_fileIds = response.data.data.material_fileIds;
          let modifyOpinion_fileIds = response.data.data.modifyOpinion_fileIds;
          this.projectForm.type = response.data.data.reportType;
          this.projectForm.year = response.data.data.year;
          this.projectForm.modifyOpinion = response.data.data.modifyOpinion;
          if (fileIds != null) {
            this.files = await getFileTypeFiles(fileIds);
          }
          if (material_fileIds != null) {
            this.material_fileIds = await getFileTypeFiles(material_fileIds);
          }
          if (modifyOpinion_fileIds != null) {
            this.modifyOpinion_fileIds = await getFileTypeFiles(modifyOpinion_fileIds);
          }
        }
      });
    },
    //弹框关闭后回调
    close () {
      this.proposal = false;
      this.reportNameList = [
        { name: "年度监测分析报告", type: "1", disable: false },
        { name: "中期评估报告", type: "2", disable: false },
        { name: "期末总结报告", type: "3", disable: false }
      ];
      this.basisFileListMixin = [];
      this.projectForm = {
        basisFileId: null,
        type: "",
        year: '',
        modifyOpinion: '',
      };
      this.files = [];
      this.material_fileIds = [],
        this.modifyOpinion_fileIds = [],
        this.modifyReportId = "";
      this.havModifyOpinion = false,
        this.look = false,
        this.fileListMixin = [];
      this.fileListtextMixin = []
    },
    // 附件下载
    downloadFile (fileId, fileName) {
      filedownload(fileId)
        .then(response => {
          if (response.status == 200) {
            this.download(response.data, fileName);
          }
        })
        .catch(error => {
          this.$notify({
            title: "失败",
            message: "上传失败[" + error + "]",
            type: "error",
            duration: 2000
          });
        });
    },
    // 下载文件
    download (data, filename) {
      if (data == null) {
      } else {
        let url = window.URL.createObjectURL(new Blob([data]));
        let link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", filename);
        document.body.appendChild(link);
        link.click();
      }
    },
    add () {
      if (!this.projectForm.type) {
        this.$notify({
          title: "警告",
          message: "请选择报告名称",
          type: "warning",
          duration: 2000
        });
        return;
      }
      if (!this.basisFileListMixin.length) {
        this.$notify({
          title: "警告",
          message: "请上传报告",
          type: "warning",
          duration: 2000
        });
        return;
      }
      if (!this.projectForm.year && this.projectForm.type == 1) {
        this.$notify({
          title: "警告",
          message: "请选择年份",
          type: "warning",
          duration: 2000
        });
        return;
      }
      if (!this.fileListtextMixin.length && this.havModifyOpinion) {
        this.$notify({
          title: "警告",
          message: "请上传修订调整建议附件",
          type: "warning",
          duration: 2000
        });
        return;
      }
      let fileIds = [];
      for (let item in this.basisFileListMixin) {
        fileIds.push(this.basisFileListMixin[item].url);
      }
      let material_fileIds = [];
      for (let item in this.fileListMixin) {
        material_fileIds.push(this.fileListMixin[item].url);
      }
      let modifyOpinion_fileIds = [];
      for (let item in this.fileListtextMixin) {
        modifyOpinion_fileIds.push(this.fileListtextMixin[item].url);
      }
      this.$confirm("确认新增?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        addReport(
          Object.assign({
            pmuc: this.reportList.pmuc,
            fileIds: fileIds,
            material_fileIds: material_fileIds,
            reportType: this.projectForm.type,
            title: this.reportList.mainTitle,
            year: this.projectForm.year,
            modifyOpinion: this.projectForm.modifyOpinion,
            modifyOpinion_fileIds: modifyOpinion_fileIds,
            havModifyOpinion: this.havModifyOpinion,
          })
        ).then(response => {
          if (response.data.code == 0) {
            this.$notify({
              title: "成功",
              message: "起草成功",
              type: "success",
              duration: 2000
            });
            this.reportVisible = false;
            this.putTableData();
          }
        });
      });
    },
    draftPlan (row) {
      if (row.category) {
        this.proposal = true
      }
      this.reportList = row;
      this.reportVisible = true;
      if (row.children) {
        for (let li of row.children) {
          if (li.reportType == '2') {
            this.reportNameList[1].disable = true
          } else if (li.reportType == '3') {
            this.reportNameList[2].disable = true
          }
        }
      }
    },
    putTableData () {
      getPlanReportPageTree(
        Object.assign({
          current: this.page.currentPage,
          size: this.page.pageSize,

        })
      ).then(response => {
        this.tableData = response.data.data.records;
        for (let li of this.tableData) {
          if (li.children) {
            li.length = li.children.length;
          }
        }
        this.page.total = response.data.data.total;
      });
    },
    searchSubmit(){
      this.page.currentPage = 1
      this.pageputTableData (this.page,this.plantitle)
    },
    resetSubmit(){
      this.plantitle= ''
      this.pageputTableData (this.page)
    },
    pageputTableData (page,title) {
      getPlanReportPageTree(
        Object.assign({
          current: page.currentPage,
          size: page.pageSize,
          titleLike: title
        })
      ).then(response => {
        this.tableData = response.data.data.records;
        this.page.total = response.data.data.total;
      });
    },
    handleSizeChange (val) {
      var page = this.page;
      page.pageSize = val;
      this.pageputTableData(page,this.plantitle);
    },
    handleCurrentChange (val) {
      var page = this.page;
      page.currentPage = val;
      this.pageputTableData(page,this.plantitle);
    },
    //行区分颜色
    tableRowClassName ({ row, rowIndex }) {
      if (row.isReport == undefined) {
        return "success-row";
      }
      return "";
    },
    solicitOpinions (row) {
      let src = `/pimSolicitOpinions/detail/${row.reportId}`;
      this.$router.push({
        path: src,
        query: {
          reportType: row.reportType,
          title: row.title,
          mainTitle: row.mainTitle,
          createUnit: row.createUnit,
          year: row.year,
        }
      });
    },
    reportOpinionHistory (row) {
      let src = `/collectionListReport/list/${row.reportId}`;
      this.$router.push({
        path: src,
        query: {
          type: "8"
        }
      });
    },
    releaseReport (row) {
      this.$confirm("确定上报报告吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        releaseReport(row.reportId).then(response => {
          this.$router.go(0)
        })
      })
    },
    viewReportRrogress (row) {
      this.havModifyIf = row.havModifyOpinion;
      if (row.reportType == '2' && row.category == 'A') {  //中期发展报告
        this.reportRrogressMedium = true;
        this.reportRrogressOthers = false;
        switch (row.reportState) {
          case "3":
            this.reportRrogressStep = 1;
            this.reportStepOne = '上报报告';
            break;
          case "4":
            this.reportRrogressStep = 0;
            this.reportStepOne = '上报报告(修改重报)';
            break;
          case "5":
            if (this.havModifyIf) {
              this.reportRrogressStep = 3;
            } else {
              this.reportRrogressStep = 2;
            }
            this.reportStepOne = '上报报告';
            break;
          case "6":
            if (this.havModifyIf) {
              this.reportRrogressStep = 5;
            } else {
              this.reportRrogressStep = 4;
            }
            this.reportStepOne = '上报报告';
            break;
          case "9":
            this.reportStepOne = '上报报告';
            this.reportRrogressStep = 1;
            this.reportTwoValidate = true;
            break;
          case "10":
            this.reportStepOne = '上报报告(修改重报)';
            this.reportRrogressStep = 1;
            break;
          case "11":
            this.reportStepOne = '上报报告';
            this.reportRrogressStep = 4;
            break;
        }
      } else {   //其他报告
        this.reportRrogressMedium = false;
        this.reportRrogressOthers = true;
        if (row.reportState == '3') {
          this.reportRrogressStepOthers = 2;
          if (row.category == 'B' && (row.planningRank == 'B' || row.planningRank == 'C')) {
            this.reportRrogressOthersStep = '抄送'
          } else {
            this.reportRrogressOthersStep = '报送'
          }
        }
      }
      this.reportRrogressVisible = true;
    },
    detailDialog (achievementId, pmuc) {
      this.achievementIdDD = achievementId;
      this.pmucDD = pmuc;
      this.showDetailDialog = true;
    },
  }
}
</script>

<style lang="scss" scoped>
.transform-deg_two {
  margin-left: 10px;

  /deep/ .el-step__line {
    transform: rotate(-25deg);
    margin-top: -54px;
  }
}

.transform-deg_line_two {
  margin-left: -270px;

  /deep/ .el-step__line {
  }
}

.reportTwoValidate {
  /deep/ .el-step__head.is-wait {
    color: #67c23a;
  }

  /deep/ .el-step__main .el-step__title.is-wait {
    color: #67c23a;
  }
}

.beian_two {
  margin-top: -134px;
  margin-left: 20px;

  /deep/ .el-step__line {
    display: none;
  }
}

.step-group {
  margin-top: 140px !important;
  margin-bottom: 1px;
}

.relateddiv {
  margin-left: 0px;
  margin-top: 0px;
}

.report /deep/ .el-form-item .el-form-item__label {
  height: 68px;
  line-height: 68px;
}

.card-body {
  padding: 10px;
  padding-bottom: 65px;
}

.paginationcss {
  margin-top: 20px;
  float: right;
  margin-right: 28px;
}

.form-item {
  font-weight: 600;
}

.dialog-footer {
  margin-left: 417px;
  position: absolute;
  bottom: 0;
}

/deep/ .el-form-item .el-form-item__label {
  font-weight: 600;
}
.myBtn{
  padding: 8px 15px;
  font-size: 14px;
  border-radius: 3px;
}

/*/deep/ .el-table .el-table__row--level-1 .is-left {*/
  /*text-decoration: underline;*/
/*}*/
</style>

